﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<PostModel>" %>
<%@ Import Namespace="FeaturesBlog.Models" %>
<%@ Import Namespace="FeaturesBlog.Helpers" %>
<div class="post">
    <div class="postSubject"><%= Html.ActionLink(Html.Encode(Model.BlogPost.PostSubject.ToString()), "Comments", "Post", new { id = Model.BlogPost.PostId }, null)%>
        <div class="postDate"><%= Html.Encode(Model.BlogPost.PostDate.ToShortDateString()) %></div>
    </div>
    <div class="postBody">
        <%= new HtmlHelpers().EncodeHtmlForPost(Model).BlogPost.PostBody.ToString()%>
    </div>
    <% if(Model.PostWithActions) 
       { %>
    <div class="postAction">
        [<%= Html.ActionLink(string.Format("{0} comments", Model.CommentsCount), "Comments", "Post", new { id = Model.BlogPost.PostId }, null) %>]
        <%if (HttpContext.Current.User.Identity.IsAuthenticated)
       { %>
        [<%= Html.ActionLink("delete", "Delete", "Home", new { id = Model.BlogPost.PostId }, new { onclick = "return confirm('Are you sure?')" })%>]
        [<%= Html.ActionLink("edit", "Edit", "Home", new { id = Model.BlogPost.PostId }, null)%>]
        <% } %>
    </div>
    <% } %>
</div>